import {
  ajax
} from "@/config/apiServer/axios-config.js";
import {
  URLS
} from "@/config/apiServer/urls.js";
import Qs from 'qs'

// 获取Banner分类
export function getBannerCategory() {
  return ajax({
    type: 'get',
    url: URLS.EXPLORER_BANNER_CATEGORY
  })
}

// 获取Banner列表
export function getBanners(pages) {
  return ajax({
    type: 'get',
    typeData: true,
    url: URLS.EXPLORER_BANNERS,
    params: pages
  })
}

// 上传banner图
export function uploadBanner(param) {
  return ajax({
    type: 'post',
    url: URLS.EXPLORER_BANNER_ADD,
    params: param
  })
}

// 删除banner图
export function delBanner(id) {
  return ajax({
    type: 'delete',
    url: URLS.EXPLORER_BANNER_DEL,
    params: {
      id
    }
  })
}

// 更新banner图
export function updateBanner(param) {
  return ajax({
    type: 'put',
    url: URLS.EXPLORER_BANNER_UPDATE,
    params: param
  })
}

// 获取应用类别列表
export function getCategorys(param) {
  return ajax({
    type: 'get',
    url: URLS.EXPLORER_CATEGORYS,
    params: param
  })
}

// 添加应用类别
export function addCategorys(param) {
  return ajax({
    type: 'post',
    url: URLS.EXPLORER_CATEGORY_ADD,
    params: Qs.stringify(param),
    header: {
      'content-type': 'application/x-www-form-urlencoded'
    }
  })
}

// 删除应用类别
export function delCategorys(param) {
  return ajax({
    type: 'delete',
    url: URLS.EXPLORER_CATEGORY_DEL,
    params: param
  })
}

// 更新应用类别
export function updateCategory(param) {
  return ajax({
    type: 'put',
    url: URLS.EXPLORER_CATEGORY_UPDATE,
    params: Qs.stringify(param),
    header: {
      'content-type': 'application/x-www-form-urlencoded'
    }
  })
}

// 获取应用列表
export function getApps(param) {
  return ajax({
    type: 'get',
    url: URLS.EXPLORER_APPS,
    params: param
  })
}

// 添加应用
export function addApps(param) {
  return ajax({
    type: 'post',
    url: URLS.EXPLORER_APP_ADD,
    params: Qs.stringify(param),
    header: {
      'content-type': 'application/x-www-form-urlencoded'
    }
  })
}

// 更新应用
export function updateApp(param) {
  return ajax({
    type: 'put',
    url: URLS.EXPLORER_APP_UPDATE,
    params: Qs.stringify(param),
    header: {
      'content-type': 'application/x-www-form-urlencoded'
    }
  })
}

// 删除应用
export function delApp(param) {
  return ajax({
    type: 'delete',
    url: URLS.EXPLORER_APP_DEL,
    params: param
  })
}